<!-- 搜索表单 -->
<template>
  <el-card  >
    <el-form
      label-width="77px"
      class="ele-form-search"
      @keyup.enter.native="search"
      @submit.native.prevent
    >
      <el-row :gutter="15">
        <el-col :lg="10" :md="12">
          <el-form-item label="关键字:">
            <el-input clearable v-model="where.keyword" placeholder="支持产品名称,编号模糊查询" />
          </el-form-item>
        </el-col>
        <el-col :lg="6" :md="12">
          <div class="ele-form-actions">
            <el-button
              type="primary"
              icon="el-icon-search"
              class="ele-btn-icon"
              @click="search"
            >
              查询
            </el-button>
            <el-button @click="reset">重置</el-button>
          </div>
        </el-col>
      </el-row>
    </el-form>
  </el-card>
  </template>
  
  <script>
    const DEFAULT_WHERE = {
      keyword: '',  //关键字
      // status:0,
    };
    import { QuerySysStatusEnum } from '@/api/enummanger';
    export default {
      name: 'productChooseSearch',
     
      data() {
        return {
          // 表单数据
          where: { ...DEFAULT_WHERE },
          statusEnums:[],
        };
      },
      //初始化数据
      created(){
       this.queryStatusEnums();
      },
  
      methods: {
  
        /* 搜索 */
        search() {
          let params = {
            pageindex: 1,
            conditions: [],
            orderBys: [{ sort: "createDate", order: 1, }],
          };
  
          //关键字查询
          if(this.where.keyword){
            params.conditions.push({
              key:"name,code",
              operator: 1,
              value: this.where.keyword,
            });
          };

          // //状态查询
          // if(this.where.status ===0 || this.where.status ===1){
          //   params.conditions.push({
          //     key:"status",
          //     operator: 0,
          //     value: this.where.status,
          //   });
          // };
  
          this.$emit('search', params);
        },
        /*  重置 */
        reset() {
          this.where = { ...DEFAULT_WHERE };
          this.search();
        },
  
        /* 系统状态 */
        async queryStatusEnums(){
          let sysEnums = await QuerySysStatusEnum();
          sysEnums.map(e=>{
            this.statusEnums.push({Key:e.Key,Value:e.Value});
          });
        },
      }
    };
  </script>